// Tags:
#include <cctype>
#include <cstdio>
#include <queue>
#include <vector>

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

const int N = 1e5 + 5;
int n, m, ans;
int e_cnt, heads[N];
bool vis[N];
std::queue<int> q;

struct Edge {
  int v, nxt;
} e[N << 2];

inline void add(int u, int v) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt;
}

inline void solve(int s) {
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = heads[u], v; i; i = e[i].nxt) {
      if (!vis[v = e[i].v]) { q.push(v), vis[v] = true; }
    }
  }
  ++ans;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen64("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen64("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("el.in", "r", stdin);
  freopen("el.out", "w", stdout);
#endif
#endif

  read(n), read(m);
  for (int i = 1, u, v; i <= m; ++i) {
    read(u), read(v);
    add(u, v), add(v, u);
  }
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) { solve(i); }
  }
  printf("%d", ans + m - n);
  return 0;
}